package com.jkkc.lib.base.entry;

import androidx.annotation.NonNull;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;

import com.blankj.utilcode.util.StringUtils;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

import com.jkkc.lib.base.interfaces.IUser;


@Entity(tableName = "jkkc_student")
public class Student implements Cloneable, IUser {

    @Expose
    @NonNull
    @PrimaryKey
    @ColumnInfo(name = "exam_number")
    private String examNumber;
    @Expose
    @ColumnInfo(name = "student_name")
    private String studentName;
    @Expose
    @ColumnInfo(name = "sex")
    private String sex;
    @Expose
    @ColumnInfo(name = "cardid")
    @SerializedName("icNumber")
    private String cardid;
    @Expose
    @ColumnInfo(name = "class_name")
    private String className;
    @Expose
    @ColumnInfo(name = "birthday")
    private String birthday;
    @Expose
    @ColumnInfo(name = "school_name")
    private String schoolName = "";
    @Expose
    @ColumnInfo(name = "identity_number")
    private String identityNumber;
    @Expose
    @ColumnInfo(name = "grade_number")
    private String gradeNumber = "";
    @Expose
    @ColumnInfo(name = "student_nation")
    private String studentNation;
    @Expose
    @ColumnInfo(name = "class_no")
    private String classNo;
    @Expose
    @ColumnInfo(name = "student_from")
    private String studentFrom;
    @Expose
    @ColumnInfo(name = "home_address")
    private String homeAddress;
    @Expose
    @ColumnInfo(name = "extend_filed")
    private String extendFiled;//延伸字段 扩展用
    @Expose
    @ColumnInfo(name = "plan_id")
    private String planId;//计划ID
    @Expose
    @ColumnInfo(name = "student_photo")
    private String studentPhoto;
    @Expose
    @ColumnInfo(name = "create_time")
    private String createTime;
    @Expose
    @ColumnInfo(name = "update_time")
    private String updateTime;

    @ColumnInfo(name = "localPath")
    private String localPath;

    // 学生唯一码(体测卡号)
    @NonNull
    @ColumnInfo(name = "student_code")
    private String studentCode = "0";

    @Ignore
    private String number;
    @Ignore
    private String qs;

    public Student() {
    }

    public static Student createTempStudent(String card) {
        Student s = new Student();
        s.setStudentName("临时");
        s.setExamNumber(card);
        s.setCardid(card);
        s.setSchoolName("临时");
        s.setGradeNumber("临时");
        s.setClassName("临时");
        s.setSex("1");
        return s;
    }

    public String getExamNumber() {
        return examNumber;
    }

    public void setExamNumber(String examNumber) {
        this.examNumber = examNumber;
    }

    public String getStudentName() {
        return studentName;
    }

    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    public String getSchoolName() {
        return schoolName;
    }

    public void setSchoolName(String schoolName) {
        this.schoolName = schoolName;
    }

    public String getIdentityNumber() {
        return identityNumber;
    }

    public void setIdentityNumber(String identityNumber) {
        this.identityNumber = identityNumber;
    }

    public String getGradeNumber() {
        return gradeNumber;
    }

    public void setGradeNumber(String gradeNumber) {
        this.gradeNumber = gradeNumber;
    }

    public String getStudentNation() {
        return studentNation;
    }

    public void setStudentNation(String studentNation) {
        this.studentNation = studentNation;
    }

    public String getClassNo() {
        return classNo;
    }

    public void setClassNo(String classNo) {
        this.classNo = classNo;
    }

    public String getStudentFrom() {
        return studentFrom;
    }

    public void setStudentFrom(String studentFrom) {
        this.studentFrom = studentFrom;
    }

    public String getHomeAddress() {
        return homeAddress;
    }

    public void setHomeAddress(String homeAddress) {
        this.homeAddress = homeAddress;
    }

    public String getExtendFiled() {
        return extendFiled;
    }

    public void setExtendFiled(String extendFiled) {
        this.extendFiled = extendFiled;
    }

    public String getPlanId() {
        return planId;
    }

    public void setPlanId(String planId) {
        this.planId = planId;
    }

    public String getStudentPhoto() {
        return studentPhoto;
    }

    public void setStudentPhoto(String studentPhoto) {
        this.studentPhoto = studentPhoto;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }

    public String getCardid() {
        return cardid;
    }

    @Override
    public Student getStudent() {
        return this;
    }

    public void setCardid(String cardid) {
        this.cardid = cardid;
    }


    @NonNull
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    public String getLocalPath() {
        return localPath;
    }

    public void setLocalPath(String localPath) {
        this.localPath = localPath;
    }

    public String getSexStr() {
        if (sex == null) return "男";

        if (sex.equals("1") || sex.equals("男")) {
            return "男";
        } else if (sex.equals("2") || sex.equals("女")) {
            return "女";
        } else {
            return sex;
        }
    }

    public static String getGradeNum(String gradeName) {
        if (StringUtils.isEmpty(gradeName)) return "";
        switch (gradeName) {
            case "小学一年级":
                return "11";
            case "小学二年级":
                return "12";
            case "小学三年级":
                return "13";
            case "小学四年级":
                return "14";
            case "小学五年级":
                return "15";
            case "小学六年级":
                return "16";
            case "初中一年级":
                return "21";
            case "初中二年级":
                return "22";
            case "初中三年级":
                return "23";
            case "高中一年级":
                return "31";
            case "高中二年级":
                return "32";
            case "高中三年级":
                return "33";
            case "大一":
                return "41";
            case "大二":
                return "42";
            case "大三":
                return "43";
            case "大四":
                return "44";
            default:
                return gradeName;
        }
    }

    public static String getGradeName(String gradeNumber) {
        if (StringUtils.isEmpty(gradeNumber)) return "";
        switch (gradeNumber) {
            case "11":
                return "小学一年级";
            case "12":
                return "小学二年级";
            case "13":
                return "小学三年级";
            case "14":
                return "小学四年级";
            case "15":
                return "小学五年级";
            case "16":
                return "小学六年级";
            case "21":
                return "初中一年级";
            case "22":
                return "初中二年级";
            case "23":
                return "初中三年级";
            case "31":
                return "高中一年级";
            case "32":
                return "高中二年级";
            case "33":
                return "高中三年级";
            case "41":
                return "大一";
            case "42":
                return "大二";
            case "43":
                return "大三";
            case "44":
                return "大四";
            default:
                return gradeNumber;
        }
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getQs() {
        return qs;
    }

    public void setQs(String qs) {
        this.qs = qs;
    }

    public String getStudentCode() {
        return studentCode;
    }

    public void setStudentCode(String studentCode) {
        this.studentCode = studentCode;
    }

    @Override
    public String toString() {
        return "Student{" +
                "examNumber='" + examNumber + '\'' +
                ", studentName='" + studentName + '\'' +
                ", sex='" + sex + '\'' +
                ", cardid='" + cardid + '\'' +
                ", className='" + className + '\'' +
                ", birthday='" + birthday + '\'' +
                ", schoolName='" + schoolName + '\'' +
                ", identityNumber='" + identityNumber + '\'' +
                ", gradeNumber='" + gradeNumber + '\'' +
                ", studentNation='" + studentNation + '\'' +
                ", classNo='" + classNo + '\'' +
                ", studentFrom='" + studentFrom + '\'' +
                ", homeAddress='" + homeAddress + '\'' +
                ", extendFiled='" + extendFiled + '\'' +
                ", planId='" + planId + '\'' +
                ", studentPhoto='" + studentPhoto + '\'' +
                ", createTime='" + createTime + '\'' +
                ", updateTime='" + updateTime + '\'' +
                ", localPath='" + localPath + '\'' +
                ", studentCode='" + studentCode + '\'' +
                ", number='" + number + '\'' +
                ", qs='" + qs + '\'' +
                '}';
    }
}
